package com.cqjtu.tto.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.cqjtu.tto.service.SysUserRoleService;
import com.cqjtu.tto.vo.Results;
import com.cqjtu.tto.vo.params.SysUserRoleParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author：monkey-L
 * @description:
 * @date: 20:09 2021/12/11
 */
@RestController
@Api(tags = "用户-角色模块")
public class SysUserRoleController {

    @Autowired
    private SysUserRoleService sysUserRoleService;

//    @SaCheckRole("admin")
    @PostMapping("sysUserRoleAdd")
    @ApiOperation(value = "为用户赋予角色")
    public Results sysUserRoleAdd(@RequestBody SysUserRoleParam sysUserRoleParam) {
        return sysUserRoleService.sysUserRoleAdd(sysUserRoleParam);
    }

//    @SaCheckRole("admin")
    @PostMapping("sysUserRoleDelete")
    @ApiOperation(value = "削减用户角色")
    public Results sysUserRoleDelete(@RequestBody SysUserRoleParam sysUserRoleParam) {
        return sysUserRoleService.sysUserRoleDelete(sysUserRoleParam);
    }

//    @SaCheckRole("admin")
    @PostMapping("sysUserRoleUpdate")
    @ApiOperation(value = "更新用户角色")
    public Results sysUserRoleUpdate(@RequestBody SysUserRoleParam sysUserRoleParam) {
        return sysUserRoleService.sysUserRoleUpdate(sysUserRoleParam);
    }

//    @SaCheckRole("admin")
    @PostMapping("sysUserRoleSelect")
    @ApiOperation(value = "查询一个用户的所有角色",notes = "根据名字查询")
    public Results sysUserRoleSelect(String userName) {
        return sysUserRoleService.sysUserRoleSelect(userName);
    }

}
